# Maintainer: Sven-Hendrik Haase <svenstaro@archlinux.org>
# Contributor: dtag <dtag00@gmail.com>
pkgname=ceres-solver
pkgver=2.2.0
pkgrel=2
pkgdesc="Solver for nonlinear least squares problems"
arch=('loong64' 'x86_64')
url="http://ceres-solver.org/"
license=('LGPL')
depends=('google-glog' 'suitesparse')
makedepends=('cmake' 'ninja' 'eigen')
optdepends=('openmp')
source=("http://ceres-solver.org/ceres-solver-${pkgver}.tar.gz")
sha256sums=('48b2302a7986ece172898477c3bcd6deb8fb5cf19b3327bc49969aad4cede82d')
options=('staticlibs')

build() {
  cd $pkgname-$pkgver
  cmake \
      -Bbuild \
      -GNinja \
      -DCMAKE_BUILD_TYPE=None \
      -DCMAKE_INSTALL_PREFIX=/usr \
      -DEIGENSPARSE=ON \
      -DBUILD_SHARED_LIBS=ON \
      -DBUILD_TESTING=OFF \
      -DBUILD_EXAMPLES=OFF \
      -DBUILD_BENCHMARKS=OFF

  ninja -C build
}

package() {
  cd $pkgname-$pkgver
  DESTDIR=$pkgdir ninja -C build install
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
